package com.djmw.mouse.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class BookmarkId implements Serializable {
    private static final long serialVersionUID = -2851727142956645430L;

    public static final int BOOKMARK_TYPE_ALL = 0;
    public static final int BOOKMARK_TYPE_POSITION = 1;
    public static final int BOOKMARK_TYPE_COMPANY = 2;

    private MemberUser memberUser;
    private Position position;
    private Company company;
    private int type;

    public BookmarkId() {
    }

    @ManyToOne
    public Position getPosition() {
        return position;
    }
    public void setPosition(Position position) {
        this.position = position;
    }

    @ManyToOne
    public Company getCompany() {
        return company;
    }
    public void setCompany(Company company) {
        this.company = company;
    }

    @ManyToOne
    public MemberUser getMemberUser() {
        return memberUser;
    }
    public void setMemberUser(MemberUser memberUser) {
        this.memberUser = memberUser;
    }

    @Column(name = "c_type")
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }

    @Override
    public int hashCode() {
        int result = (position != null ? position.hashCode() : 0);
        result = 31 * result + (company != null ? company.hashCode() : 0);
        result = 31 * result + (memberUser != null ? memberUser.hashCode() : 0);
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        BookmarkId bookmark = (BookmarkId) obj;
        if (position != null ? !position.equals(bookmark.position) : bookmark.position != null) {
            return false;
        }
        if (company != null ? !company.equals(bookmark.company) : bookmark.company != null) {
            return false;
        }
        return true;
    }
}
